package com.shelpe.services.sinbad.entity.jpa.vo;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import lombok.Data;

@Data
@JsonInclude(Include.NON_NULL)
public class ConvertPlatformVo {

	@JsonProperty("pc_nonSearch_in")
	private boolean pcNonSearchIn; // pc定向站内：1
	@JsonProperty("pc_nonSearch_out")
	private boolean pcNonSearchOut; // pc定向站外：2
	@JsonProperty("pc_search_in")
	private boolean pcSearchIn; // pc搜索站内：1
	@JsonProperty("pc_search_out")
	private boolean pcSearchOut; // pc搜索站外：2，4

	@JsonProperty("wire_in")
	private boolean wireIn; // 无线站内：8
	@JsonProperty("wire_out")
	private boolean wireOut; // 无线站外：16

	@JsonProperty("outside_discount")
	private int outsideDiscount; // 溢价的百分比，必须是大于等于 1小于等于200的整数
	@JsonProperty("mobile_discount")
	private int mobileDiscount; // 无线折扣百分比。必须大于等于1，小于等于200的整数

	public List<Integer> toSearchChannels() {
		List<Integer> listsearch = new ArrayList<Integer>();
		if (this.isPcSearchIn() == true) {
			listsearch.add(1);
		}
		if (this.isPcSearchOut() == true) {
			listsearch.add(2);
			listsearch.add(4);
		}
		if (this.isWireIn() == true) {
			listsearch.add(8);
		}
		if (this.isWireOut() == true) {
			listsearch.add(16);
		}
		return listsearch;
	}

	public List<Integer> toNonsearchChannels() {
		List<Integer> listNonsearch = new ArrayList<Integer>();
		if (this.isPcNonSearchIn() == true) {
			listNonsearch.add(1);
		}
		if (this.isPcNonSearchOut() == true) {
			listNonsearch.add(2);
		}
		if (this.isWireIn() == true) {
			listNonsearch.add(8);
		}
		if (this.isWireOut() == true) {
			listNonsearch.add(16);
		}
		return listNonsearch;
	}

	public void fromSearch(PlatformVo vo) {
		if (vo != null && vo.getSearchChannels() != null && vo.getSearchChannels().getNumber() != null) {
			if (vo.getSearchChannels().getNumber().contains(1)) {
				this.pcSearchIn = true;
			}
			if (vo.getSearchChannels().getNumber().contains(2) && vo.getSearchChannels().getNumber().contains(4)) {
				this.pcSearchOut = true;
			}
			if (vo.getSearchChannels().getNumber().contains(8)) {
				this.wireIn = true;
			}
			if (vo.getSearchChannels().getNumber().contains(16)) {
				this.wireOut = true;
			}
		}
	}

	public void fromNonSearch(PlatformVo vo) {
		if (vo != null && vo.getNonsearchChannels() != null && vo.getNonsearchChannels().getNumber() != null) {
			if (vo.getNonsearchChannels().getNumber().contains(1)) {
				this.pcNonSearchIn = true;
			}
			if (vo.getNonsearchChannels().getNumber().contains(2)) {
				this.pcNonSearchOut = true;
			}
			if (vo.getNonsearchChannels().getNumber().contains(8)) {
				this.wireIn = true;
			}
			if (vo.getNonsearchChannels().getNumber().contains(16)) {
				this.wireOut = true;
			}
		}
	}

}
